package com.df.springmvc.system.manage.controller;

import java.util.HashMap;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import com.df.springmvc.common.bean.MsgBean;
import com.df.springmvc.common.util.WebUtil;
import com.df.springmvc.supper.SupperController;
import com.df.springmvc.system.manage.services.InitServices;


@Controller
@RequestMapping("/system/manage/Init")
/**
 * 本类仅做一些简单数据处理如:
 *格式验证
 *数据封装
 * @author David
 *
 */
public class InitController extends SupperController{
	String page_="system/manage/" + this.getClass().getSimpleName().replace("Controller","") + "_";
	@Autowired
	InitServices services;
	
	public InitController(){
		// TODO Auto-generated constructor stub
	}
	@Override
	@RequestMapping("/")
	public String excute(ModelMap model,HttpServletRequest request,HttpServletResponse response){
		// TODO Auto-generated method stub
		try{
		}catch(Exception e){
			// TODO: handle exception
			e.printStackTrace();
		}finally{
		}
		return page_;
	}
	@Override
	@RequestMapping("/doUpd")
	public void doUpd(ModelMap model,HttpServletRequest request,HttpServletResponse response){
		// TODO Auto-generated method stub
		try{
			HashMap<String,String> paramMap=getParamMap(request,"map");
			Object rs=services.deal(paramMap);
			WebUtil.json(response,new MsgBean(rs,true));
		}catch(Exception e){
			// TODO: handle exception
			e.printStackTrace();
			WebUtil.json(response,new MsgBean(e.getMessage(),false));
		}finally{
		}
		super.doUpd(model,request,response);
	}
	@Override
	@RequestMapping("/doView")
	public void doView(ModelMap model,HttpServletRequest request,HttpServletResponse response){
		// TODO Auto-generated method stub
		try{
			HashMap<String,String> paramMap=getParamMap(request,"map");
			Object rs=services.doView(paramMap);
			WebUtil.json(response,new MsgBean(rs,true));
		}catch(Exception e){
			// TODO: handle exception
			e.printStackTrace();
			WebUtil.json(response,new MsgBean(e.getMessage(),false));
		}finally{
		}
		super.doView(model,request,response);
	}
	@RequestMapping("/queryFileTree")
	public void queryFileTree(ModelMap model,HttpServletRequest request,HttpServletResponse response){
		// TODO Auto-generated method stub
		try{
			HashMap<String,String> paramMap=getParamMap(request,"map");
			Object rs=services.queryFileTree();
			WebUtil.json(response,new MsgBean(rs,true));
		}catch(Exception e){
			// TODO: handle exception
			e.printStackTrace();
			WebUtil.json(response,new MsgBean(e.getMessage(),false));
		}finally{
		}
	}
}
